<?php

use Illuminate\Database\Seeder;

class CommissionLogTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {

        // 设置amount = 2 的用户type = 1
        try{
            DB::beginTransaction ();
            $ids = DB::table ("commission_log")->select ("id")->where ("amount",'=', 2)->get()->toArray();
            foreach ($ids as $id){
                DB::update("update commission_log set `type` = 1  where amount = ? ", [$id->id]);
            }
            $items = DB::select ("select user_id , sum(amount), from commission_log group by user_id where  type =1");



        }catch (Exception $e){
            echo $e->getMessage ();
        }
    }
}
